<template>
	<view class="content">
		<button type="primary" @click="chushihua">初始化成员</button>
		<u--form labelPosition="left" :model="model1" ref="form1" class="form-box">
			<!-- <u-form-item label="序号" borderBottom ref="item5">
				<u--input v-model="model1.userInfo.index" border="none"></u--input>
			</u-form-item> -->
			<u-form-item label="题目" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.timu" border="none"></u--input>
			</u-form-item>

			<u-form-item label="选项" borderBottom ref="item2">
				<u--input v-model="model1.userInfo.xuanxiang" border="none"></u--input>
			</u-form-item>
			<u-form-item label="正确答案" borderBottom ref="item3">
				<u--input v-model="model1.userInfo.daan" border="none"></u--input>
			</u-form-item>
			<u-form-item label="大区" borderBottom ref="item4">
				<u-radio-group v-model="model1.userInfo.area" @change="radioGroupChange"
					style="display: flex;flex-wrap: wrap;">
					<u-radio @change="radioChange" v-for="(item, index) in areaList" :key="index" :name="item.name"
						:disabled="item.disabled" :label="item.name" style="margin-right: 10px;margin-bottom: 10px;">
					</u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="类型" borderBottom ref="item4">
				<u-radio-group v-model="model1.userInfo.type" @change="radioGroupChange1">
					<u-radio @change="radioChange1" v-for="(item, index) in typeList" :key="index" :name="item.key"
						:disabled="item.disabled" :label="item.name" style="margin-right: 10px;">
					</u-radio>
				</u-radio-group>
			</u-form-item>
		</u--form>
		<u-button @click="submit">提交</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model1: {
					userInfo: {
						xuanxiang: '',
						timu: '',
						area: '',
						daan: '',
						// index: '',
						type: ''
					},
				},
				areaList: [{
						name: '瑞奇',
						disabled: false
					},
					{
						name: '风和',
						disabled: false
					},
					{
						name: '派尔特',
						disabled: false
					},
					{
						name: '公用',
						disabled: false
					}
				],
				typeList: [{
						name: '单选',
						key: 'danxuan',
						disabled: false
					},
					{
						name: '多选',
						key: 'duoxuan',
						disabled: false
					},
					{
						name: '判断',
						key: 'panduan',
						disabled: false
					}
				]
			}
		},
		methods: {
			radioChange(e) {
				console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				console.log(e);
			},
			radioChange1(e) {
				console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange1(e) {
				console.log(e);
			},
			submit() {
				console.log(this.model1.userInfo)
				uniCloud.callFunction({
					name: 'add-timu',
					data: Object.assign(this.model1.userInfo, {
						flag: 'timu'
					})
				}).then(res => {
					console.log(res)
				})
			},
			chushihua() {
				uniCloud.callFunction({
					name: 'reset-user'
				}).then(res => {
					console.log(res)
				})
			}
		}
	}
</script>

<style>
	.content {
		/* width: 100% !important; */
		padding: 30rpx;
	}

	.form-box {
		width: 100%;
	}
</style>
